package com.example.aircraftwar.codes.strategy;

import android.content.Context;

import com.example.aircraftwar.codes.aircraft.AbstractAircraft;
import com.example.aircraftwar.codes.bullet.BaseBullet;
import com.example.aircraftwar.codes.bullet.BossBullet;
import com.example.aircraftwar.codes.bullet.EnemyBullet;

import java.util.LinkedList;
import java.util.List;

/**
 * Boss一次散射三发子弹的射击方式
 *
 */

public class EnemyBossShoot implements ShootStrategy {
    private int direction = 1;
    private int shootNum = 5;
    private int power = 20;

    @Override
    public List<BaseBullet> executeShootStrategy(Context context, AbstractAircraft abstractAircraft) {
        List<BaseBullet> res = new LinkedList<>();
        int x = abstractAircraft.getLocationX();
        int y = abstractAircraft.getLocationY() + direction * 320;
        int[] speedX = {-6,-2,0,2,6};
        int[] speedY = {10,20,10,20,10};
        BaseBullet baseBullet;
        for (int i = 0; i < shootNum; i++) {
            // 子弹发射位置相对飞机位置向前偏移
            // 多个子弹横向分散
            baseBullet = new BossBullet(context, x + (i * 2 - shootNum + 1) * 10, y, speedX[i], speedY[i], power);
            res.add(baseBullet);
        }
        return res;
    }
}
